<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.text.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"   pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>IPL 5 - RED</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="content-language" content="" />
    <link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%@ include file="global.jsp" %>
<%
String userName = (String) session.getAttribute("userName");
String league = (String) session.getAttribute("league");
String parameter = request.getParameter("matchId");
System.out.println("parameter:::"+parameter);
String matchId = parameter.substring(0,parameter.indexOf("*"));
System.out.println("matchId:::"+matchId);
if(null != userName){
String resposeText = "";
String errorMesg = (String) session.getAttribute("error");
out.println("<script>alert(\\"+errorMesg+"\\)</script>");
if (session.getAttribute("resposeText") != null) {

	if(null != (String)session.getAttribute("resposeText")){ 
		out.println("<script>alert("+(String)session.getAttribute("resposeText")+")</script>");
    }else{
    	out.println("<script>alert(\"No Mesg\")</script>");
    }
	
	if(("Succesfully Submited").equals((String)session.getAttribute("resposeText"))){ 
		out.println("<script>alert(\"Succesfully Submited\")</script>");
    }else if(("User Not Registered").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"User Not Registered\")</script>");
    }else if(("Entry already made").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"Entry already made\")</script>");
    }else if(("Please enter your name").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"Please enter your name\")</script>");
    }else if(("Exception Occurred").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"Exception Occurred\")</script>");
    }else if(("Unauthorized User").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"Unauthorized User\")</script>");
    }else if(("UserName Not Entered").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"UserName Not Entered\")</script>");
    }else{
    	out.println("<script>alert(\\"+errorMesg+"\\)</script>");
    } 
} 
%>


    <div id="page">
        <div id="header">
            <h1><a href="#">IPL-5  2012</a></h1>
        </div>
        <%@ include file="links.jsp" %>
        
         
        <div id="main">		              
            <div id="content">	
			
             <h1>Points Table</h1>
             <center>
             <table align="left" border="1" cellspacing="2" cellpadding="2" width="90%">
             <th><font color="yellow">Match ID</th>
             <th><font color="yellow">User Name</th>
             <th><font color="yellow">Winner Points</th>
             <th><font color="yellow">Mom Points</th>
             <th><font color="yellow">Sixes Points</th>
             <th><font color="yellow">Total points</th>
			<%
				try {
					Class.forName(db_driver);
					Connection conn = DriverManager.getConnection(db_url, db_user, db_password);
					Statement stmt = conn.createStatement();
					System.out.print("select matchId, voterId, winner, mom, sixes, total from points where league='"+league+"' and matchId='"+matchId+"' order by total desc");
					ResultSet rset = stmt.executeQuery("select matchId, voterId, winner, mom, sixes, total from points where league='"+league+"' and matchId='"+matchId+"' order by total desc");

					while (rset.next()) {
						%>
						<tr>
							<td align="center"><%=rset.getString(1)%></td>
							<td align="center"><%=rset.getString(2)%></td>
							<td align="center"><%=rset.getString(3)%></td>
							<td align="center"><%=rset.getString(4)%></td>
							<td align="center"><%=rset.getString(5)%></td>
							<td align="center"><%=rset.getString(6)%></td>
						</tr>
						<%
					}
					%>
					</table>
					<center>
					<%
					rset.close();
					stmt.close();
					conn.close();
					
				} catch (Exception e1) {
					e1.printStackTrace();
				} finally {
				}
			%>
		</table>
               
                      
            </div><!-- content -->
                       
            <div class="clearing">&nbsp;</div>   
        </div><!-- main -->
    </div><!-- page -->
    <div id="footer">
        <p>Copyright &copy; 2010, designed by <a href="http://www.kiranvenkat.in/">kiranvenkat.in</a></p>
    </div>
</body>
</html>
<%
   if ( session.getAttribute("resposeText") != null && !("").equals(session.getAttribute("resposeText")))
   { 
		session.setAttribute("resposeText", null);
   }

}else {
	%>
		<jsp:forward   page="login.jsp"/>
	<%
}
%>
